Skip to content

Comments

fix: add SearchPath comparison to functionsEqualExceptAttributes#235

Merged
tianzhou merged 1 commit intopgplex:mainfrom
asonawalla:fix/search-path-diff-detection
Jan 6, 2026
Merged

fix: add SearchPath comparison to functionsEqualExceptAttributes#235
tianzhou merged 1 commit intopgplex:mainfrom
asonawalla:fix/search-path-diff-detection

Conversation

@asonawalla
Copy link
Contributor

Summary

  • Fixed bug where SET search_path changes were detected but silently dropped (no DDL generated)
  • Added missing SearchPath field comparison to functionsEqualExceptAttributes() in internal/diff/function.go
  • Extended existing alter_function_attributes test case to cover SearchPath changes

Root Cause

The functionsEqualExceptAttributes() function was missing a SearchPath comparison, while the other two comparison functions (functionsEqual and functionsEqualExceptComment) correctly compared it. This caused the function to incorrectly return true when only SearchPath differed, entering the attribute-only branch which only handles Parallel and IsLeakproof.

Test plan

  • Added test function to existing alter_function_attributes test case
  • Verified test fails before fix (SearchPath change produces no DDL)
  • Verified test passes after fix (SearchPath change produces CREATE OR REPLACE)
  • PGSCHEMA_TEST_FILTER="create_function/alter_function_attributes" go test -v ./internal/diff -run TestDiffFromFiles
  • PGSCHEMA_TEST_FILTER="create_function/alter_function_attributes" go test -v ./cmd -run TestPlanAndApply

🤖 Generated with Claude Code

The functionsEqualExceptAttributes() function was missing a SearchPath
field comparison. This caused SET search_path changes to be detected
but silently dropped — no DDL was generated.

The other two comparison functions (functionsEqual and
functionsEqualExceptComment) correctly compare SearchPath. This fix
aligns functionsEqualExceptAttributes with them.

Added test case to alter_function_attributes to verify SearchPath
changes generate CREATE OR REPLACE FUNCTION statements.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Contributor

@tianzhou tianzhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tianzhou tianzhou merged commit 540dceb into pgplex:main Jan 6, 2026
1 check passed
alecthomas pushed a commit to alecthomas/pgschema that referenced this pull request Jan 26, 2026
…lex#235)

The functionsEqualExceptAttributes() function was missing a SearchPath
field comparison. This caused SET search_path changes to be detected
but silently dropped — no DDL was generated.

The other two comparison functions (functionsEqual and
functionsEqualExceptComment) correctly compare SearchPath. This fix
aligns functionsEqualExceptAttributes with them.

Added test case to alter_function_attributes to verify SearchPath
changes generate CREATE OR REPLACE FUNCTION statements.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants